﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;

using Domain.Model.Abstract;
using Domain.Model.Mapping.Conventions;
using Domain.Model.Mapping.Overrides;

using FluentNHibernate.Automapping;

namespace Domain.Model.Mapping  
{
    public class DomainMapping
    {
        /// <summary>
        /// Creates an AutoPersistenceModel used for auto-mapping.
        /// </summary>
        /// <returns value="AutoPersistenceModel"></returns>
        public static AutoPersistenceModel CreateMappings()
        {
            return AutoMap.AssemblyOf<Domain.Model.Program>()
            .Where(t => t.Namespace == "Domain.Model")
            // Conventions
            .Conventions.AddFromAssemblyOf<CustomForeignKeyConvention>()
            // Mapping Overrides
            .UseOverridesFromAssemblyOf<FormElementMappingOverride>();
        }
    }
}